﻿<%@ Page language="C#"     %> 

<%@ Register Tagprefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 
<%@ Register Tagprefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %> 

<%@ Import Namespace="Microsoft.SharePoint" %> 

<%@ Register Tagprefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>  

<html>
<head>
    <title>Content editor</title>
    
    <SharePoint:CssLink runat="server"/>
	<SharePoint:Theme runat="server"/>
    <SharePoint:CssLink runat="server"/>
    
    <SharePoint:ScriptLink ID="ScriptLink1" language="javascript" name="core.js" runat="server" />
    <SharePoint:ScriptLink ID="ScriptLink2" language="javascript" name="form.js" runat="server" />

    <link rel="Stylesheet" href="../PageActionEditor.css" type="text/css" />
    
    <script type="text/javascript">
        var hiddenField = null;
        
        function PrepareContents(id) {
            var obj1 = RTE_GetEditorDocument(id);
            if (obj1 != null)
                RTE_GetEditorDocument(id).body.innerHTML = hiddenField.value;
            else
                document.getElementById(id).value = hiddenField.value;
        }        
        
        function Init() {
            if (typeof (dialogArguments) == "undefined")
                document.getElementById("OKButton").disabled = true;
            else
                hiddenField = dialogArguments;
        
            window.onresize = resize;

            document.body.onkeypress = function() {
                if (window.event.keyCode == 27)
                        self.close();
            }

            resize();

            window.setTimeout("if(hiddenField != null) PrepareContents('InputFormTextBox1')", 500);
        }

        function resize() {
            var obj1 = document.getElementById("InputFormTextBox1_toolbar");
            if (obj1 != null) {
                obj1.style.width = (parseInt(document.body.offsetWidth) + 0) + "px";
                obj1.style.borderRight = "none";

                obj1 = document.getElementById("InputFormTextBox1_iframe");
                obj1.style.width = (parseInt(document.body.offsetWidth) - 2) + "px";
                //obj1.style.height = (parseInt(document.body.offsetHeight) - 90) + "px";
                obj1.style.height = (parseInt(document.body.offsetHeight) - (obj1.offsetTop + 42)) + "px";
            }
            else {
                obj1 = document.getElementById("InputFormTextBox1");
                obj1.style.width = (parseInt(document.body.offsetWidth) - 2) + "px";
                obj1.style.height = (parseInt(document.body.offsetHeight) - (obj1.offsetTop + 42)) + "px";
            }
        }

        function UpdateHiddenField() {
            if (hiddenField != null) {
                var obj1 = RTE_GetEditorDocument("InputFormTextBox1");
                if (obj1 != null)
                    hiddenField.value = obj1.body.innerHTML;
                else
                    hiddenField.value = document.getElementById("InputFormTextBox1").value;
            }
            self.close();
        }
    </script>
    
    <script runat="server">
        public void Page_Load(object sender, EventArgs e)
        {
            bool isRichText = Convert.ToBoolean(this.Request.QueryString["isRichText"]);
            this.InputFormTextBox1.RichText = isRichText;
        }
    </script>
</head>
<body onload="Init()">
    <form id="form1" runat="server">    
        <SharePoint:InputFormTextBox 
            runat="server" ID="InputFormTextBox1"
            AllowHyperlink="true"
            RichTextMode="FullHtml"
            RichText= "true"             
            TextMode="MultiLine"
            Width="100%" Height="100%">
        </SharePoint:InputFormTextBox>
        <div style="text-align: right; padding: 0px; padding-right: 3px; padding-top: 8px;">
            <input type="button" class="UserButton" value="OK" id="OKButton" onclick="UpdateHiddenField();" />&nbsp;<input type="button" class="UserButton" value="Cancel" onclick="self.close();" />
        </div>        
    </form>
</body>
</html>
